<?php

class My_Resource_View extends Zend_Application_Resource_ResourceAbstract
{

	protected $_view;


	public function init()
	{
		// Return view so bootstrap will store it in the registry
		return $this->getView();
	}

	public function getView()
	{
		if (null === $this->_view)
		{
			// set view helper
			//$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
			$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
			
			$view = new Naneau_View_Smarty(array('compile_dir'     => APPLICATION_PATH . '/data/compile',
												 'cache_dir'       => APPLICATION_PATH . '/data/cache',
												 'left_delimiter'  => '<!--{',
												 'right_delimiter' => '}-->'));

			$viewRenderer->setView($view)
				->setViewBasePathSpec(APPLICATION_PATH . '/templates')
				->setViewScriptPathSpec('app/:module/:controller/:action.:suffix')
				->setViewSuffix('tpl');

			//Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
			
            $viewRenderer->setView($view);
			
			$this->_view = $view;
		}

		return $this->_view;
	}
}
